<?php
$isLocal = $_SERVER['SERVER_NAME'] === "localhost";

if ($isLocal) {
	$host = "localhost";
	$user = "root";
	$pass = "";
	$db_name = "";
} else {
	$host = "";
	$user = "";
	$pass = "";
	$db_name = "";
}

$conn = @mysql_connect($host, $user, $pass);

if (!$conn) {die("连接数据库失败：" . mysql_error());}

mysql_select_db($db_name, $conn);

//字符转换，读库
mysql_query("set character set utf8");
//写库
mysql_query("set names utf8");
?>